describe('Testing UsersCtrl', function() {
    // declaring variables in this scope which
    // should be used in tests below
    // and will be injected on beforeEach execution
    var $rootScope, $scope;

    beforeEach(module('MyApp'));
    beforeEach(inject(function($controller, _$rootScope_, user, users){
        // reseting the upper scope
        $rootScope = _$rootScope_;
        $scope = $rootScope.$new();
        // creating the controller
        $controller('UsersCtrl', {
            '$scope': $scope,
            '$rootScope' : $rootScope,
            'user': user,
            'users': users
        });
    }));


    it('$scope.step == 1', function() {
        // since beforeEach is called
        // and we have access to $scope variable
        // via the parent scope
        // ve can do
        expect($scope.step).toBe(1);
    });

    it('checking if user step will change on valid input', function() {
        // beforeEach is called once again, the variables in
        // the parent scope are rest
        expect($scope.step).toBe(1);

        // fill valid input
        $scope.user.email = 'valid@email.com';
        $scope.user.password = 'morethan5';
        expect($scope.user.validate()).toBe(true);

        $scope.nextStep();
        expect($scope.step).toBe(2);

    })
})